<!DOCTYPE html>
{% load staticfiles %}
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Show</title>
</head>
<body>
{% for teacher in teachers %}
<h1>{{ teacher.no }}{{ teacher.name }}</h1>
<p>{{ teacher.intro }}</p>
<hr>
<p>{{ teacher.motto }}</p>
<hr>
<!--<img  src="{{ teacher.photo }}"/>-->
<img  src="{% static 'images/johnkuo.jpeg' %}"/>
<hr>
subject:<b>{{ teacher.subject }}</b>
manger:<b>{{ teacher.manager }}</b>
<hr>
<!--<button>{{ teacher.good_count }}</button>-->
<!--<button>{{ teacher.bad_count }}</button>-->
<a href="/good/{{ teacher.no }}"
   class="button">好评({{ teacher.gcount }})</a>
<a href="/bad/{{ teacher.no }}"
   class="button">差评({{ teacher.bcount }})</a>
{% endfor %}

<script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
<script>
  $(function () {
    $('.button').on('click', function (e) {
      e.preventDefault()
      var $a = $(e.target)
      var url = $a.attr('href')

      $.ajax({
        'url': url,
        'type': 'get',
        'dataType': 'json',
        'success': function(res) {
          if (res.code === 200) {
            $a.text(res.result)
            alert(res.result)
          }
        }
      })
    })
  })
</script>
</body>
</html>